package zhishu.iceyyy.com.bxq_2500.api;

import android.text.TextUtils;
import android.util.Log;

import java.util.HashMap;
import java.util.Map;

import zhishu.iceyyy.com.bxq_2500.base.BaseApplication;
import zhishu.iceyyy.com.bxq_2500.utils.DeviceUtil;
import zhishu.iceyyy.com.bxq_2500.utils.JSONUtils;


/**
 * Created by 他的猫 on 2017/5/10.
 */

public class API {

    public static final String Base = "http://39.100.44.196:8080/";


    /**
     * 版本接口
     *
     * @param
     * @param
     * @param handler
     */
    public static void version(Okhttp.Objectcallback handler) {
        Map<String, String> map = new HashMap<>();
        map.put("mac_package", DeviceUtil.getPackageName(BaseApplication.getInstance()));
        map.put("mac_version", DeviceUtil.getVersionCode(BaseApplication.getInstance()));

        String s = JSONUtils.mapToJson(map);
        Log.e("json", "xx" + s);


        Okhttp.post(Base + "movice/mSystem/version", s, handler);

    }


    /**
     * 获取分类
     *
     * @param handler
     */
    public static void Movicetype(Okhttp.Objectcallback handler) {


        Okhttp.post(Base + "movice/mMovice/type", "", handler);

    }

    /**
     * 获取分类视频
     *
     * @param type_id
     * @param handler
     */
    public static void moviceList(String type_id, Okhttp.Objectcallback handler) {
        Map<String, String> map = new HashMap<>();
        map.put("type_id", type_id);

        String s = JSONUtils.mapToJson(map);
        Log.e("json", "xx" + s);
        Okhttp.post(Base + "movice/mMovice/moviceList", s, handler);

    }

    /**
     * 搜索接口
     *
     * @param vod_name
     * @param page
     * @param handler
     */
    public static void search(String vod_name, String page, Okhttp.Objectcallback handler) {
        Map<String, String> map = new HashMap<>();
        if (TextUtils.isEmpty(vod_name)) {
            map.put("vod_name", "");
        } else {
            map.put("vod_name", vod_name);
        }

        map.put("page", page);
        String s = JSONUtils.mapToJson(map);
        Log.e("json", "xx" + s);
        Okhttp.post(Base + "movice/mMovice/search", s, handler);

    }

    /**
     * 视频详情
     *
     * @param vod_time
     * @param vod_id
     * @param handler
     */
    public static void moviceDetail(String vod_time, String vod_id, Okhttp.Objectcallback handler) {
        Map<String, String> map = new HashMap<>();
        map.put("vod_time", vod_time);
        map.put("vod_id", vod_id);
        String s = JSONUtils.mapToJson(map);
        Log.e("json", "xx" + s);
        Okhttp.post(Base + "movice/mMovice/moviceDetail", s, handler);

    }

    public static void addCollection(String vod_id, Okhttp.Objectcallback handler) {
        Map<String, String> map = new HashMap<>();

        map.put("vod_id", vod_id);
        String s = JSONUtils.mapToJson(map);
        Log.e("json", "xx" + s);
        Okhttp.post(Base + "movice/mUser/addCollection", s, handler);

    }

    /**
     * 获取分享地址
     *
     * @param
     * @param handler
     */
    public static void shareurl(Okhttp.Objectcallback handler) {

        Okhttp.post(Base + "movice/mSystem/shareurl", "", handler);

    }

    public static void mine(Okhttp.Objectcallback handler) {

        Okhttp.post(Base + "movice/mSystem/mine", "", handler);

    }


}
